﻿<div class="k-block divToolbar" style="margin: 5px">
    <div style="display: inline-block; ">
        <select id="selArchive" style="width: 300px"></select>
    </div>
</div>

<div class="k-block divToolbar" style="margin: 5px">
    <div style="display: inline-block;">
        <select id="selSubject" style="width: 220px"></select>
    </div>
    <div style="display: inline-block;">
        <select id="selClass"></select>
    </div>
    <div style="display: inline-block;">
        <select id="selSex">
            <option value="0" selected="selected">全部性别</option>
            <option value="1">男</option>
            <option value="2">女</option>
        </select>
    </div>
    <button class="k-button" onclick="Filter()"><span class="k-icon k-i-search"></span><span>搜索</span></button>
    <a class="k-button" onclick="Export()"><span class="k-icon k-i-calendar"></span><span>导出成绩</span></a>
</div>

<div class="ph-tabs" style="margin:5px">
    <ul>
        <li class="k-state-active">成绩计数统计</li>
        <li>免试数据</li>
    </ul>
    <div>
        <div id="grid_statistic" style="text-align: center"></div>
    </div>
    <div>
        <div id="grid_autoPass" style="text-align: center"></div>
    </div>
</div>

<script class="init">
    LocatedMenu("体测数据", "成绩情况");

    $("#selArchive").kendoDropDownList({
        dataTextField: "Title",
        dataValueField: "Guid",
        dataSource: Whale.dataSource({
            url: "/Achievements/Archive/Gets",
            getParameters: function () {
                return {
                    aType: 2,
                    expired: false
                }
            }
        }),
        dataBound: function (e) {
            if (this.dataSource.data().length == 0) {
                this.setDataSource(new kendo.data.DataSource({
                    data: [{ Title: "暂无档案", Guid: "" }]
                }));
            }
        }
    });

    $("#selSex").kendoDropDownList();

    $("#selClass").kendoDropDownList({
        optionLabel: {
            ID: 0,
            ClassName: "所有班级"
        },
        dataTextField: "ClassName",
        dataValueField: "ID",
        dataSource: Whale.dataSource({
            url: "/School/Class/GetClasses",
            getParameters: function () {
                return { schoolGuid: "@PH.Web.Global.WebContext.CurrentSchool.Guid" }
            }
        })
    });

    $("#selSubject").kendoDropDownList({
        optionLabel: {
            ID: 0,
            SubjectName: "所有项目"
        },
        dataTextField: "SubjectName",
        dataValueField: "ID",
        dataSource: Whale.dataSource({
            url: "/Standard/Subject/GetSubjects"
        })
    });

    function Filter() {
        $("#grid_statistic").data("kendoGrid").dataSource.page(0);
    }
</script>

<script class="grid_statistic_config">
    function GetMarkCount(p, m) {
        var html = m;
        if (m - p != 0) {
            html += "<span>" + (m - p) + "</span>";
        }
        return html;
    }

    $(function () {
        var fields = [{
            title: "班级",
            field: "ClassName",
            width: 150
        }, {
            title: "项目",
            field: "SubjectName",
            width: 200
        }, {
            title: "实际人数",
            field: "PersonCount",
            width: 100
        }, {
            title: "成绩个数",
            field: "MarkCount",
            width: 100
        }, {
            title: "差额",
            template: "#=PersonCount-MarkCount#",
            width: 100
        }, {}];

        $("#grid_statistic").kendoGrid({
            columns: fields,
            dataSource: Whale.dataSource({
                url: "/Achivevments/Mark/GetMarkStatisticByClass",
                getParameters: function () {
                    var cid = $("#selClass").data("kendoDropDownList").value();
                    var sid = $("#selSubject").data("kendoDropDownList").value();
                    return {
                        aGuid: $("#selArchive").data("kendoDropDownList").value(),
                        classID: cid == "" ? 0 : cid,
                        subjectID: sid == "" ? 0 : sid
                    };
                },
                pageSize: 20

            }),
            pageable: {
                messages: {
                    empty: "暂无数据"
                }
            },
            dataBound: function (e) {
                //让表头居中
                $("th.k-header").attr("style", "text-align:center; font-weight:bold;");
            }
        });
    });
</script>

<script class="grid_autopass_config">
    $(function () {
        var fields = [{
            title: "身份证",
            field: "StudentNo",
            sortable: false,
            width: 130
        }, {
            title: "班级",
            field: "ClassName",
            sortable: false,
            width: 130
        }, {
            title: "姓名",
            field: "StudentName",
            sortable: false,
            width: 100
        }, {
            title: "性别",
            field: "Sex",
            template: "#=GetSexString(Sex)#",
            sortable: false,
            width: 60
        }, {
            title: "项目",
            field: "Subject.SubjectName",
            sortable: false,
            width: 200
        }, {}];

        $("#grid_autoPass").kendoGrid({
            columns: fields,
            dataSource: Whale.dataSource({
                url: "/Achivevments/Mark/Gets",
                getParameters: function () {
                    var cid = $("#selClass").data("kendoDropDownList").value();
                    var sid = $("#selSubject").data("kendoDropDownList").value();
                    return {
                        aGuid: $("#selArchive").data("kendoDropDownList").value(),
                        sGuid: "@PH.Web.Global.WebContext.CurrentSchool.Guid",
                        classID: cid == "" ? 0 : cid,
                        subjectID: sid == "" ? 0 : sid,
                        sex: $("#selSex").data("kendoDropDownList").value(),
                        getSubject: true,
                        autoPass: true
                    };
                },
                pageSize: 20,
                serverSorting: true,
                sort: {
                    field: "Score",
                    dir: "desc"
                }
            }),
            pageable: {
                messages: {
                    empty: "暂无数据"
                }
            },
            dataBound: function (e) {
                //让表头居中
                $("th.k-header").attr("style", "text-align:center; font-weight:bold;");
            },
            sortable: true
        });
    });
</script>
